{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "215a957c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Python3_Jupyter_Nb_Pandas_CSV数据调整.ipynb\n",
    "# Create By GF 2023-12-15 15:13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ef80a529",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fca7d6be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "xj_date                 object\n",
       "xj_year_month           object\n",
       "xj_year                  int64\n",
       "xj_month                 int64\n",
       "xj_year_half             int64\n",
       "xj_week_sn               int64\n",
       "xj_week_what_day         int64\n",
       "xj_date_level            int64\n",
       "xj_day_level_name       object\n",
       "xj_ent_system           object\n",
       "xj_ent_depart           object\n",
       "xj_ent_bo               object\n",
       "xj_ent_center           object\n",
       "xj_sto_id                int64\n",
       "xj_sto_name             object\n",
       "xj_sto_level            object\n",
       "xj_sto_status           object\n",
       "xj_sto_open             object\n",
       "xj_sto_close            object\n",
       "xj_sto_close_deco       object\n",
       "xj_sto_cls_dec_days    float64\n",
       "xj_region_class         object\n",
       "xj_region_biz_id         int64\n",
       "xj_region_biz           object\n",
       "xj_gr_p                float64\n",
       "xj_gr_p_md_avg         float64\n",
       "xj_gr_p_yd_avg         float64\n",
       "xj_gr_p_m_sum          float64\n",
       "xj_gr_p_y_sum          float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"C:\\\\GF-Datas\\\\xunjie_store_gross_profit_data.csv\", header=0)\n",
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b7d4f1cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "日期           object\n",
       "年月           object\n",
       "年             int64\n",
       "月             int64\n",
       "半年            int64\n",
       "周序列           int64\n",
       "周内第几天         int64\n",
       "日期等级          int64\n",
       "日等级名称        object\n",
       "企业体系         object\n",
       "企业部门         object\n",
       "企业分公司        object\n",
       "企业中心         object\n",
       "门店ID          int64\n",
       "门店名称         object\n",
       "门店等级         object\n",
       "门店状态         object\n",
       "门店开店日期       object\n",
       "门店闭店日期       object\n",
       "门店闭店装修       object\n",
       "门店闭店装修天数    float64\n",
       "区域类别         object\n",
       "区域商圈ID        int64\n",
       "区域商圈         object\n",
       "毛利          float64\n",
       "毛利月日均       float64\n",
       "毛利年日均       float64\n",
       "毛利月合计       float64\n",
       "毛利年合计       float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.rename(columns={\"xj_date\"             : \"日期\",             # (Date)\n",
    "                        \"xj_year_month\"       : \"年月\",             # (Year Month)\n",
    "                        \"xj_year\"             : \"年\",               # (Year)\n",
    "                        \"xj_month\"            : \"月\",               # (Month)\n",
    "                        \"xj_year_half\"        : \"半年\",             # (Year Half)\n",
    "                        \"xj_week_sn\"          : \"周序列\",           # (Week Serial Number)\n",
    "                        \"xj_week_what_day\"    : \"周内第几天\",       # (What Day of Week)\n",
    "                        \"xj_date_level\"       : \"日期等级\",         # (Date Level)\n",
    "                        \"xj_day_level_name\"   : \"日等级名称\",       # (Day Level Name)\n",
    "                        \"xj_ent_system\"       : \"企业体系\",         # (Enterprise System)\n",
    "                        \"xj_ent_depart\"       : \"企业部门\",         # (Enterprise Department)\n",
    "                        \"xj_ent_bo\"           : \"企业分公司\",       # (Enterprise Branch Office)\n",
    "                        \"xj_ent_center\"       : \"企业中心\",         # (Enterprise Center)\n",
    "                        \"xj_sto_id\"           : \"门店ID\",           # (Store ID)\n",
    "                        \"xj_sto_name\"         : \"门店名称\",         # (Store Name)\n",
    "                        \"xj_sto_level\"        : \"门店等级\",         # (Store Level)\n",
    "                        \"xj_sto_status\"       : \"门店状态\",         # (Store Status)\n",
    "                        \"xj_sto_open\"         : \"门店开店日期\",     # (Store Open Date)\n",
    "                        \"xj_sto_close\"        : \"门店闭店日期\",     # (Store Close Date)\n",
    "                        \"xj_sto_close_deco\"   : \"门店闭店装修\",     # (Store Close Decoration)\n",
    "                        \"xj_sto_cls_dec_days\" : \"门店闭店装修天数\", # (Store Close Decoration Days)\n",
    "                        \"xj_region_class\"     : \"区域类别\",         # (Region Class)\n",
    "                        \"xj_region_biz_id\"    : \"区域商圈ID\",       # (Region Business ID)\n",
    "                        \"xj_region_biz\"       : \"区域商圈\",         # (Region Business)\n",
    "                        \"xj_gr_p\"             : \"毛利\",             # (Gross Profit)\n",
    "                        \"xj_gr_p_md_avg\"      : \"毛利月日均\",       # (Gross Profit by Month Days Average)\n",
    "                        \"xj_gr_p_yd_avg\"      : \"毛利年日均\",       # (Gross Profit by Year Days Average)\n",
    "                        \"xj_gr_p_m_sum\"       : \"毛利月合计\",       # (Gross Profit Assess By Month)\n",
    "                        \"xj_gr_p_y_sum\"       : \"毛利年合计\"        # (Gross Profit Assess By Year)\n",
    "                        })\n",
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "13546ecd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>年月</th>\n",
       "      <th>年</th>\n",
       "      <th>月</th>\n",
       "      <th>半年</th>\n",
       "      <th>周序列</th>\n",
       "      <th>周内第几天</th>\n",
       "      <th>日期等级</th>\n",
       "      <th>日等级名称</th>\n",
       "      <th>企业体系</th>\n",
       "      <th>...</th>\n",
       "      <th>门店闭店装修</th>\n",
       "      <th>门店闭店装修天数</th>\n",
       "      <th>区域类别</th>\n",
       "      <th>区域商圈ID</th>\n",
       "      <th>区域商圈</th>\n",
       "      <th>毛利</th>\n",
       "      <th>毛利月日均</th>\n",
       "      <th>毛利年日均</th>\n",
       "      <th>毛利月合计</th>\n",
       "      <th>毛利年合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2023-12-1</td>\n",
       "      <td>2023-12</td>\n",
       "      <td>2023</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>形象</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>外围</td>\n",
       "      <td>1</td>\n",
       "      <td>街铺-复合商圈</td>\n",
       "      <td>5463.4820</td>\n",
       "      <td>932.1438</td>\n",
       "      <td>2986.2225</td>\n",
       "      <td>28896.4580</td>\n",
       "      <td>8.391285e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2023-12-1</td>\n",
       "      <td>2023-12</td>\n",
       "      <td>2023</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>华为</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>二级</td>\n",
       "      <td>1</td>\n",
       "      <td>街铺-复合商圈</td>\n",
       "      <td>797.0600</td>\n",
       "      <td>488.4829</td>\n",
       "      <td>2850.2785</td>\n",
       "      <td>15142.9700</td>\n",
       "      <td>1.040352e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2023-12-1</td>\n",
       "      <td>2023-12</td>\n",
       "      <td>2023</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>形象</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>市区</td>\n",
       "      <td>1</td>\n",
       "      <td>街铺-复合商圈</td>\n",
       "      <td>8958.6260</td>\n",
       "      <td>1507.2637</td>\n",
       "      <td>5941.4147</td>\n",
       "      <td>46725.1740</td>\n",
       "      <td>2.168616e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-12-1</td>\n",
       "      <td>2023-12</td>\n",
       "      <td>2023</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>华为</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>市区</td>\n",
       "      <td>1</td>\n",
       "      <td>街铺-复合商圈</td>\n",
       "      <td>9307.5600</td>\n",
       "      <td>1301.8320</td>\n",
       "      <td>5087.1898</td>\n",
       "      <td>40356.7930</td>\n",
       "      <td>1.856824e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2023-12-1</td>\n",
       "      <td>2023-12</td>\n",
       "      <td>2023</td>\n",
       "      <td>12</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>形象</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>外围</td>\n",
       "      <td>4</td>\n",
       "      <td>综合体外商圈</td>\n",
       "      <td>6211.2890</td>\n",
       "      <td>1499.3798</td>\n",
       "      <td>8515.9118</td>\n",
       "      <td>46480.7730</td>\n",
       "      <td>1.209259e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242744</th>\n",
       "      <td>2020-11-30</td>\n",
       "      <td>2020-11</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>华为</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>外围</td>\n",
       "      <td>2</td>\n",
       "      <td>街铺-通讯商圈</td>\n",
       "      <td>4833.8001</td>\n",
       "      <td>9250.0507</td>\n",
       "      <td>7162.2882</td>\n",
       "      <td>277501.5208</td>\n",
       "      <td>2.621397e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242745</th>\n",
       "      <td>2020-11-30</td>\n",
       "      <td>2020-11</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>华为</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>市区</td>\n",
       "      <td>2</td>\n",
       "      <td>街铺-通讯商圈</td>\n",
       "      <td>10656.1399</td>\n",
       "      <td>13551.0060</td>\n",
       "      <td>11660.3379</td>\n",
       "      <td>406530.1786</td>\n",
       "      <td>4.267684e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242746</th>\n",
       "      <td>2020-11-30</td>\n",
       "      <td>2020-11</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>形象</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>市区</td>\n",
       "      <td>2</td>\n",
       "      <td>街铺-通讯商圈</td>\n",
       "      <td>8101.0500</td>\n",
       "      <td>15973.0122</td>\n",
       "      <td>8099.1046</td>\n",
       "      <td>479190.3653</td>\n",
       "      <td>2.964272e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242747</th>\n",
       "      <td>2020-11-30</td>\n",
       "      <td>2020-11</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>华为</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>郊县</td>\n",
       "      <td>2</td>\n",
       "      <td>街铺-通讯商圈</td>\n",
       "      <td>6717.7333</td>\n",
       "      <td>8343.3631</td>\n",
       "      <td>6323.4247</td>\n",
       "      <td>250300.8925</td>\n",
       "      <td>2.314373e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>242748</th>\n",
       "      <td>2020-11-30</td>\n",
       "      <td>2020-11</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>49</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>工作日</td>\n",
       "      <td>形象</td>\n",
       "      <td>...</td>\n",
       "      <td>正常</td>\n",
       "      <td>NaN</td>\n",
       "      <td>郊县</td>\n",
       "      <td>1</td>\n",
       "      <td>街铺-复合商圈</td>\n",
       "      <td>6131.8600</td>\n",
       "      <td>5872.4590</td>\n",
       "      <td>4932.9640</td>\n",
       "      <td>176173.7710</td>\n",
       "      <td>1.805465e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>242749 rows × 29 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                日期       年月     年   月  半年  周序列  周内第几天  日期等级 日等级名称 企业体系  ...  \\\n",
       "0        2023-12-1  2023-12  2023  12   2   49      6     1   工作日   形象  ...   \n",
       "1        2023-12-1  2023-12  2023  12   2   49      6     1   工作日   华为  ...   \n",
       "2        2023-12-1  2023-12  2023  12   2   49      6     1   工作日   形象  ...   \n",
       "3        2023-12-1  2023-12  2023  12   2   49      6     1   工作日   华为  ...   \n",
       "4        2023-12-1  2023-12  2023  12   2   49      6     1   工作日   形象  ...   \n",
       "...            ...      ...   ...  ..  ..  ...    ...   ...   ...  ...  ...   \n",
       "242744  2020-11-30  2020-11  2020  11   2   49      2     1   工作日   华为  ...   \n",
       "242745  2020-11-30  2020-11  2020  11   2   49      2     1   工作日   华为  ...   \n",
       "242746  2020-11-30  2020-11  2020  11   2   49      2     1   工作日   形象  ...   \n",
       "242747  2020-11-30  2020-11  2020  11   2   49      2     1   工作日   华为  ...   \n",
       "242748  2020-11-30  2020-11  2020  11   2   49      2     1   工作日   形象  ...   \n",
       "\n",
       "       门店闭店装修 门店闭店装修天数 区域类别  区域商圈ID     区域商圈          毛利       毛利月日均  \\\n",
       "0          正常      NaN   外围       1  街铺-复合商圈   5463.4820    932.1438   \n",
       "1          正常      NaN   二级       1  街铺-复合商圈    797.0600    488.4829   \n",
       "2          正常      NaN   市区       1  街铺-复合商圈   8958.6260   1507.2637   \n",
       "3          正常      NaN   市区       1  街铺-复合商圈   9307.5600   1301.8320   \n",
       "4          正常      NaN   外围       4   综合体外商圈   6211.2890   1499.3798   \n",
       "...       ...      ...  ...     ...      ...         ...         ...   \n",
       "242744     正常      NaN   外围       2  街铺-通讯商圈   4833.8001   9250.0507   \n",
       "242745     正常      NaN   市区       2  街铺-通讯商圈  10656.1399  13551.0060   \n",
       "242746     正常      NaN   市区       2  街铺-通讯商圈   8101.0500  15973.0122   \n",
       "242747     正常      NaN   郊县       2  街铺-通讯商圈   6717.7333   8343.3631   \n",
       "242748     正常      NaN   郊县       1  街铺-复合商圈   6131.8600   5872.4590   \n",
       "\n",
       "             毛利年日均        毛利月合计         毛利年合计  \n",
       "0        2986.2225   28896.4580  8.391285e+05  \n",
       "1        2850.2785   15142.9700  1.040352e+06  \n",
       "2        5941.4147   46725.1740  2.168616e+06  \n",
       "3        5087.1898   40356.7930  1.856824e+06  \n",
       "4        8515.9118   46480.7730  1.209259e+06  \n",
       "...            ...          ...           ...  \n",
       "242744   7162.2882  277501.5208  2.621397e+06  \n",
       "242745  11660.3379  406530.1786  4.267684e+06  \n",
       "242746   8099.1046  479190.3653  2.964272e+06  \n",
       "242747   6323.4247  250300.8925  2.314373e+06  \n",
       "242748   4932.9640  176173.7710  1.805465e+06  \n",
       "\n",
       "[242749 rows x 29 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6c2a80f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv(\"./讯捷集团_毛利数据_门店毛利数据_2020年11月30日-2023年12月01日.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c13c72e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
